package com.example.homemodule.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.examination.mlib.constants.ARouterConstants;
import com.examination.mlib.constants.ClickApi;
import com.examination.mlib.constants.KitArouterConstants;
import com.examination.mlib.interfaceapi.HomeBackApi;
import com.yilijk.base.utils.ClickUtils;

public class HomeUtils {

    private static HomeUtils homeUtil;
    private Context mContext;


    public HomeUtils() {

    }

    public HomeUtils(Context context) {
        this.mContext = context;
    }




    public static HomeUtils getHomeUtil(Context context) {
        homeUtil = new HomeUtils(context);
        return homeUtil;
    }

    public static HomeUtils getHomeUtil() {
        homeUtil = new HomeUtils();
        return homeUtil;
    }

    /**
     * ReactNativePage:DoctorStudio
     * 医生工作室
     * @param doctorId  医生Id
     * @param source  渠道编码
     * @param selectIndex   0-ETP  1-问诊
     * @param jumpStudioType 1-普通图文 2-预约图文 3-电话问诊 4-视频问诊
     */
    public void jumpNativePage_DoctorStudio(long doctorId,String source,int selectIndex,int jumpStudioType){
        ClickUtils.sendEvent(ClickApi.Mine.click_mydoctor1, mContext, "跳转到医生工作室");
        Bundle bundle = new Bundle();
        if (!TextUtils.isEmpty(source)){
            bundle.putString("source",source);
        }
        bundle.putLong("doctorId", doctorId);
        bundle.putInt("selectIndex", selectIndex < 0 ? 0 : selectIndex);
        bundle.putInt("jumpStudioType", jumpStudioType <= 0 ? 1 : jumpStudioType);
        push(mContext, KitArouterConstants.IM_DOCTORBUNDLE, KitArouterConstants.Message.DoctorStudio, bundle);
    }


    /**
     * android-rn
     *
     * @param context
     * @param pluginId
     * @param componentName
     */
    public static void push(Context context, String pluginId, String componentName) {
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.Android2RnPush(context, pluginId, componentName);
    }

    /**
     * rn-android
     *
     * @param context
     * @param pluginId
     * @param componentName
     * @param bundle
     */
    public static void push(Context context, String pluginId, String componentName, Bundle bundle) {
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.Android2RnPush(context, pluginId, componentName, bundle);
    }

    /**
     * @param activity activity
     */
    public static View getMainTabLayoutView(Activity activity) {
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        return homeBackApi.getMainTabLayoutView(activity);
    }

    /**
     * @param activity activity
     */
    public static void getHomePagePatientPopup(Activity activity) {
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.homePagePatientPopup(activity);
    }

    public static void goHome(Context context){
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.goHome(context);
    }


    public static void toJumeLiveList(){
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.toJumeLiveList();
    }

    public static void toJumeLiveDetail(int id,int client){
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.toJumeLiveDetail(id,client);
    }

    public static void toBannerClick(String urlString){
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.toBannerClick(urlString);
    }


    public static void toScheme(Context context,String h5Url) {
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.toScheme(context,h5Url);
    }

    public static void sendBrocast(Context context,String pageName,String params){
        HomeBackApi homeBackApi = (HomeBackApi) ARouter.getInstance().build(ARouterConstants.HomeModuleImpl).navigation();
        homeBackApi.sendBrocast(context,pageName,params);
    }

}
